//package com.lagou.service.impl;
//
//import com.lagou.entity.GoodDetail;
//import com.lagou.repository.GoodRepository;
//import com.lagou.service.IGoodService;
//import com.lagou.service.IRedisService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//import java.util.Optional;
//
//@Service
//public class GoodServiceImpl implements IGoodService {
//
//    @Autowired
//    private GoodRepository goodRepository;
//
//    @Autowired
//    private IRedisService redisService;
//
//    @Override
//    public List<GoodDetail> findAll() {
//        return goodRepository.findAll();
//    }
//
//    @Override
//    public Optional<GoodDetail> findById(Integer id) {
//        return this.goodRepository.findById(id);
//    }
//
//    @Override
//    public void save(GoodDetail goodDetail) {
//        this.goodRepository.save(goodDetail);
//    }
//
//    @Override
//    public void incGoodNumber(Integer goodId, int in) {
//        final Optional<GoodDetail> optional = this.goodRepository.findById(goodId);
//        optional.ifPresent((goodDetail) -> {
//            goodDetail.setNumber(goodDetail.getNumber() + in);
//            this.goodRepository.save(goodDetail);
//        });
//        redisService.incGoodNumber(goodId, in);
//    }
//}
